package com.salmon.study;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

@ConfigurationProperties(prefix = "app.salmon")
public class User {

    private String name;

    private Integer age;

    @NestedConfigurationProperty
    private Cache cache = new Cache();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Cache getCache() {
        return cache;
    }

    public void setCache(Cache cache) {
        this.cache = cache;
    }

    /**
     * The cache configuration for the for login users and token.
     */
    public static class Cache {

        /**
         * The maximum number of entries that the cache should contain.
         */
        private long maxSize = 2048L;

        /**
         * The max age in seconds after which the entry should be invalidated.
         */
        private long maxAge = 30L;

        public long getMaxSize() {
            return maxSize;
        }

        public void setMaxSize(long maxSize) {
            this.maxSize = maxSize;
        }

        public long getMaxAge() {
            return maxAge;
        }

        public void setMaxAge(long maxAge) {
            this.maxAge = maxAge;
        }
    }
}
